import threading

import pymongo

client = pymongo.MongoClient(host='192.168.2.159', port=27017)
# 选择数据库
db = client.hawk
# 选择集合
collection = db.txt


def insert_line(collection, file_path):
	print("execute file-->", file_path)
	with open(file_path, 'r', encoding='utf-8') as f:
		for line in f.readlines():
			if len(line) < 2:
				continue
			collection.insert_one({"sentence": line.strip()})


t1 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\wffs.txt"), name='LoopThread1')
# t2 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\js.txt"), name='LoopThread2')
# t3 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\jstm.txt"), name='LoopThread2')
# t4 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\tsxk.txt"), name='LoopThread2')
# t5 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\xylz.txt"), name='LoopThread2')
# t6 = threading.Thread(target=insert_line, args=(collection, "F:\\txt\\ztj.txt"), name='LoopThread2')

t1.start()
# t2.start()
# t3.start()
# t4.start()
# t5.start()
# t6.start()

# insert_line(collection, "F:\\txt\\xcb.txt")
# print("xcb.txt")
#
# insert_line(collection, "F:\\txt\\dpcq.txt")
# print("dpcq.txt")
#
# insert_line(collection, "F:\\txt\\dldl.txt")
# print("dldl.txt")
